<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>最终表相关</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
</head>
<body>
<!-- 查询条件开始 -->
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 5px;">
    <legend>查询条件</legend>
</fieldset>
<blockquote class="layui-elem-quote">
    <form action="" method="post" id="searchFrm" lay-filter="searchFrm" class="layui-form layui-form-pane">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">课程名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="name" autocomplete="off" class="layui-input">
                </div>
            </div>
            <button type="button" class="layui-btn" lay-submit="" lay-filter="doSearch"><span
                    class="layui-icon layui-icon-search"></span>查询
            </button>
            <button type="reset"
                    class="layui-btn layui-btn-warm"><span
                    class="layui-icon layui-icon-refresh-1"></span>重置
            </button>
        </div>
    </form>
</blockquote>
<!-- 查询条件结束-->

<!-- 数据表格开始 -->
<div>
    <table class="layui-hide" id="courseTable" lay-filter="courseTable"></table>

    <div id="courseRowBar" style="display: none;">
        <button type="button" lay-event="Analysis" class="layui-btn layui-btn-sm"><span
                class="layui-icon layui-icon-set"></span>考核环节情况分析表
        </button>
        <button type="button" lay-event="conclude" class="layui-btn layui-btn-sm layui-btn-warm"><span
                class="layui-icon layui-icon-face-smile"></span>课程目标达成
        </button>
    </div>
</div>
<!-- 数据表格结束 -->

<!--分析表弹出层开始-->
<div id="analyzeDiv" style="display: none;">
    <div id="table1" style="display: none;">
        <table class="layui-hide" id="analyzeTable1" lay-filter="analyzeTable1"></table>
    </div>
    <div id="table2" style="display: none;">
        <table class="layui-hide" id="analyzeTable2" lay-filter="analyzeTable2"></table>
    </div>
    <div id="table3" style="display: none;">
        <table class="layui-hide" id="analyzeTable3" lay-filter="analyzeTable3"></table>
    </div>
    <div id="table4" style="display: none;">
        <table class="layui-hide" id="analyzeTable4" lay-filter="analyzeTable4"></table>
    </div>
    <div id="table5" style="display: none;">
        <table class="layui-hide" id="analyzeTable5" lay-filter="analyzeTable5"></table>
    </div>
</div>
<script type="text/html" id="analyzeTablebar">
    <a class="layui-btn layui-btn-xs" lay-event="save">保存</a>
</script>
<!--分析表弹出层结束-->

<!--最终表展示开始-->
<div id="concludeDiv" style="display: none;">
    <table class="layui-hide" id="concludeTable" lay-filter="concludeTable"></table>
</div>
<!--最终表展示结束-->


<script type="text/javascript" src="/layuiadmin/layui/layui.js"></script>
<script type="text/javascript">
    layui.use(['jquery', 'form', 'table', 'layer'], function () {
        var $ = layui.jquery;
        var form = layui.form;
        var table = layui.table;
        var layer = layui.layer;
        //表格加载
        tableIns = table.render({
            elem: '#courseTable'
            , url: '/courses/page'
            , toolbar: '#courseToolBar' //开启头部工具栏，并为其绑定左侧模板
            , title: '课程数据表'
            , height: 'full-280'
            , page: true
            , method: 'post'
            , cols: [
                [
                    {field: 'id', title: 'ID', align: 'center'}
                    , {field: 'name', title: '课程名称', align: 'center'}
                    , {fixed: 'right', title: '操作', toolbar: '#courseRowBar', align: 'center'}
                ]
            ]
        });

        //条件查询监听
        form.on("submit(doSearch)", function (data) {
            tableIns.reload({
                where: data.field,
                page: {
                    curr: 1
                }
            });
            return false;
        });

        //监听行工具条的事件
        table.on("tool(courseTable)", function (obj) {
            var data = obj.data; //获得当前行数据
            switch (obj.event) {
                case 'Analysis':
                    Analysis(data);
                    break;
                case 'conclude':
                    conclude(data);
                    break;
            }
        });

        //打开考核环节情况分析表
        function Analysis(data) {
            layerIndex = layer.open({
                type: 1,
                content: $("#analyzeDiv"),
                area: ['1200px', '700px'],
                maxmin: true,
                shadeClose: true,
                title: '评判标准',
                success: function () {
                    var i = 1;
                    while (i <= 5) {
                        $("#table" + i).hide();
                        i++;
                    }
                    //更具课程ID查询 每个考核环节的考核与评价标准 表
                    $.get("/courses/findAnalyze/" + data.id, function (res) {
                        if (res.code == -1) {
                            layer.msg(res.msg)
                            layer.close(layerIndex);
                        }
                        //循环设置table1-5
                        $.each(res.data, function (index, item) {
                            var j = index + 1;
                            $("#table" + j).show();
                            table.render({
                                elem: '#analyzeTable' + j
                                , id: "analyzeTable" + j
                                , data: item
                                , title: '数据表'
                                , width: 1180
                                , cols: [
                                    [
                                        {field: 'checkId', title: '考核环节ID', align: 'center', hide: true}
                                        , {field: 'checkevaluationId', title: '表3ID', align: 'center', hide: true}
                                        , {field: 'courseId', title: '课程ID', align: 'center', hide: true}
                                        , {field: 'name', title: '考核环节', align: 'center'}
                                        , {field: 'target', title: '课程目标', align: 'center'}
                                        , {field: 'inOutline', title: '考核环节在大纲分值', align: 'center'}
                                        , {field: 'checkAverage', title: '考核环节平均分值', align: 'center'}
                                        , {field: 'checkDegree', title: '考核环节达成度', align: 'center'}
                                    ]
                                ]
                            });
                        });
                    });
                }
            });
        }


        //打开课程目标达成
        function conclude(data) {
            layerIndex = layer.open({
                type: 1,
                content: $("#concludeDiv"),
                area: ['1200px', '700px'],
                maxmin: true,
                shadeClose: true,
                title: '最终表',
                success: function () {
                    //更具课程ID查询 每个考核环节的考核与评价标准 表
                    $.get("/courses/findConclude/" + data.id, function (res) {
                        layerIndex = table.render({
                            elem: '#concludeTable'
                            , id: "concludeTable"
                            , data: res.data
                            , height: 'full-300'
                            , size: 'lg'
                            , toolbar: '#'
                            , title: '最终表'
                            , cols: [
                                [
                                    {field: 'courseName', title: '课程', align: 'center'}
                                    ,{field: 'content', title: '指标点', align: 'center'}
                                    , {field: 'power', title: '权重系数', align: 'center'}
                                    , {field: 'points', title: '考核总分', align: 'center'}
                                    , {field: 'average', title: '考核平均分', align: 'center'}
                                    , {field: 'conclude', title: '达成度', align: 'center'}
                                ]
                            ]
                        });
                    });
                }
            });
        }

    });
</script>
</body>
</html>